package top.infopub.job.common;


import java.util.Arrays;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;


/**
 * dubbo访问日志
 * @author Awoke
 * @version 2018年9月27日
 * @see DubboLogAop
 * @since
 */
@Component
@Aspect
public class DubboLogAop {

    private static final Logger logger = LoggerFactory.getLogger(DubboLogAop.class);

    @Pointcut("execution (* top.infopub.*.wsImpl.*.*(..)) ")
    public void pointcut() {}

    @Before("pointcut()")
    public void before() {}

    @Around("pointcut()")
    public Object around(ProceedingJoinPoint point)
        throws Throwable {
        logger.info("dubbo-call {}", point.getSignature().toString());
        logger.info("params: {}", Arrays.toString(point.getArgs()));
        Object object = point.proceed();
        logger.info("return: {}", object == null ? "" : object.toString());
        return object;
    }

}
